﻿using NUnit.Framework;
using WordStudy20250123.T002;

namespace WordStudy20250123.T003
{
    [TestFixture]
    class CsvTest01
    {

        [Test]
        public void Test01()
        {
            var columnNames = new List<string> { "Time [s]", "P1+ []", "Ubc []", "Ip1+ []" };
            var result = CsvHelper.ParseCsv(@"D:\data\WordStudy20250123\FileTest01\K=1-重载-两相-0%Un-第二次.csv", columnNames);

            foreach (var columnName in columnNames)
            {
                Console.WriteLine($"Values for {columnName}: {result[columnName].Count}");
            }
        }

        [Test]
        public void TestProcessCsvFile()
        {
            string filePath = @"D:\data\WordStudy20250123\CsvTest01\充电测试.csv";
            int skipLines = 1; // 跳过CSV文件的第一行（通常是标题行）
            int batchSize = 10; // 每次读取10行数据

            Func<List<string[]>, bool> processBatch = (batch) =>
            {
                // 处理数据的逻辑
                foreach (var row in batch)
                {
                    Console.WriteLine(string.Join(", ", row));
                }

                // 返回false表示继续处理，返回true表示结束处理
                return false;
            };

            CsvHelper.ProcessCsvFile(filePath, skipLines, batchSize, processBatch);
        }
    }
}
